package com.longge;

public class RemoveAlmostEqualCharacters {

    public int removeAlmostEqualCharacters(String word) {

        char[] chars = word.toCharArray();
        int operations = 0;
        for (int i = 0, j = 1; i < chars.length - 1; ) {
            if (chars[i] == chars[j] || Math.abs(chars[i] - chars[j]) == 1) {
                operations++;
                i += 2;
                j += 2;
            } else {
                i++;
                j++;
            }
        }

        return operations;
    }
}
